<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      new Promise((resolve, reject) => {
        if (Math.random() > 0.5) {
          resolve("成功");
        } else {
          reject("失败");
        }
      })
        .then((res) => {
          console.log(res);
        })
        .catch((err) => {
          console.error(err);
        })
        .finally(() => {
          console.log("无论成功还是失败都会执行");
        });
    </script>
  </body>
</html>
